package com.ym.consumer.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DeadMQConfig {
    @Bean
    public DirectExchange normalExchange(){
        return ExchangeBuilder.directExchange("normal.exchange").build();
    }
    @Bean
    public Queue normalQueue(){
        return QueueBuilder.durable("normal.queue")
                .withArgument("x-dead-letter-exchange",deadExchange().getName())
                .withArgument("x-dead-letter-routing-key","dead")
                .build();
    }
    @Bean
    public Binding normalBinding(){
        return BindingBuilder.bind(normalQueue()).to(normalExchange()).with("normal");
    }

    @Bean
    public DirectExchange deadExchange(){
        return ExchangeBuilder.directExchange("dead.exchange").build();
    }
    @Bean
    public Queue deadQueue(){
        return QueueBuilder.durable("dead.queue").build();
    }
    @Bean
    public Binding deadBinding(){
        return BindingBuilder.bind(deadQueue()).to(deadExchange()).with("dead");
    }

}
